#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Validators for labman2 data model and labman2 data form fields"""

from django.utils.translation import ugettext as _
from django.core.validators import RegexValidator, slug_re
import re
#from django.core.exceptions import ValidationError

# pylint: disable=C0103
validate_newltype = RegexValidator(slug_re, _(u'Link type should '
                        'consists of only letters, numbers, underscores '
                        'or hyphens'), 'newltype')

# pylint: disable=C0103
doi_re = re.compile(r'[doi|DOI][\s\.\:]{0,2}(10\.\d{4}[\d\:\.\-\/a-z]+)[A-Z\s]')
#doi_re = re.compile('\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])\S)+)\b')

validate_doi = RegexValidator(doi_re, _(u"Invalid ")) # pylint: disable=C0103
